package br.com.kallango.server.protocolo;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.filter.codec.ProtocolEncoderAdapter;

public class BeanProtocolo implements ProtocolCodecFactory {

	public static int QTD_CARACTERES_TAMANHO = 8;
	
	private ProtocolEncoderAdapter codificaProtocolo;
	private ProtocolDecoderAdapter decodificaProtocolo;
	
	{
		setCodificaProtocolo(new CodificaProtocolo());
		setDecodificaProtocolo(new DecodificaProtocolo());
	}
	
	@Override
	public ProtocolDecoder getDecoder(IoSession arg0) throws Exception {
		return getDecodificaProtocolo();
	}

	@Override
	public ProtocolEncoder getEncoder(IoSession arg0) throws Exception {
		return getCodificaProtocolo();
	}

	public void setCodificaProtocolo(ProtocolEncoderAdapter codificaProtocolo) {
		this.codificaProtocolo = codificaProtocolo;
	}

	public ProtocolEncoderAdapter getCodificaProtocolo() {
		return codificaProtocolo;
	}

	public void setDecodificaProtocolo(ProtocolDecoderAdapter decodificaProtocolo) {
		this.decodificaProtocolo = decodificaProtocolo;
	}

	public ProtocolDecoderAdapter getDecodificaProtocolo() {
		return decodificaProtocolo;
	}

}
